package com.dongge.action;

import com.dongge.common.FileUtils;
import com.opensymphony.xwork2.ActionSupport;

import java.io.File;

/**
 * Created by Administrator on 2015/10/2.
 * 单个文件上传的例子
 */
public class SingleFileUpload extends ActionSupport {
    private File file;
    private String fileName;
    private String contentType;

    /**
     * <form method = "post" enctype="multipart/form-data">
     *     <input type="file" name="upXX">
     * </form>
     * @param file
     */
    public void setUpXX(File file) {
        this.file = file;
    }

    public void setUpXXFileName(String fileName) {
        this.fileName = fileName;
    }

    public void setUpXXContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getFileName() {
        return fileName;
    }

    public String getContentType() {
        return contentType;
    }

    @Override
    public String execute() throws Exception {
        String outPath = "D:/upload/"+fileName;
        FileUtils.copyFile(file,outPath);
        System.out.println("test");
        return SUCCESS;
    }

}
